package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.EcologyHatchRatio;
import com.sc.nft.enums.metamap.HatchRatioTypeEnum;
import com.sc.nft.mapper.EcologyHatchRatioMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * 熔炼权益配置(sc_ecology_hatch_ratio)数据DAO
 *
 * @author jinpinhai
 * @since 2024-09-06 16:29:30
 */
@Slf4j
@Repository
public class EcologyHatchRatioDao extends ServiceImpl<EcologyHatchRatioMapper, EcologyHatchRatio> {

    public List<EcologyHatchRatio> findMetaMapRatio(List<HatchRatioTypeEnum> hatchRatioTypeEnums) {
        LambdaQueryWrapper<EcologyHatchRatio> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(EcologyHatchRatio::getRatioType, hatchRatioTypeEnums);
        return list(wrapper);
    }

    public Boolean updateMetaMapRatio(Long id, BigDecimal shareRatio) {
        LambdaUpdateWrapper<EcologyHatchRatio> wrapper = Wrappers.lambdaUpdate();
        wrapper.eq(EcologyHatchRatio::getId, id);
        wrapper.set(EcologyHatchRatio::getShareRatio, shareRatio);
        return update(wrapper);
    }
}